﻿<UserControl x:Class="CornerstoneRemoteControlClient.Views.DataViews.DataTrafficDataView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    
    <UserControl.Resources>
        <Style x:Key="DataRepresentationStyle" TargetType="TextBlock">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsSentData}" Value="True">
                    <Setter Property="TextBlock.Foreground" Value="Green"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding IsSentData}" Value="False">
                    <Setter Property="TextBlock.Foreground" Value="Yellow"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="Data traffic to and from Cornerstone." Style="{StaticResource HeaderText16}" Margin="5"/>
            <Button Grid.Column="1" Content="Clear" Padding="5" HorizontalAlignment="Right" Command="{Binding ClearCommand}"/>
        </Grid>

        <ScrollViewer Grid.Row="1" Background="Black" VerticalScrollBarVisibility="Auto" Margin="5,10">
            <ItemsControl ItemsSource="{Binding Data.ObservableCollection}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width=".5*"/>
                                <ColumnDefinition Width=".5*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding ByteRepresentation}" TextWrapping="Wrap" Margin="5" Grid.Column="0" Style="{StaticResource DataRepresentationStyle}"/>
                            <TextBlock Text="{Binding ReadableRepresentation}" TextWrapping="Wrap" Margin="5" Grid.Column="1" Style="{StaticResource DataRepresentationStyle}"/>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>
